
#include "klib.h"
#include "bit.h"
#include "var.h"
#include <stdio.h>

void *bit_read(void *value, const void *base, int offset, size_t bitsize)
{
	int i;
	if (bitsize == 0) {
		return NULL;
	}
	for (i = 0; i < bitsize; i++) {
		if (bit_get(base, offset + i)) {
			bit_set(value, i);
		}
	}
	return value;
}

void bit_test()
{
	char buffer[128];
	unsigned int i, x;
	for (i = 0; i < 32; i++) {
		x = 0xFFFFFFFF;
		bit_clr(&x, i);
		printf("%08x: ", x);
		printf("%s\n", strbin(buffer, sizeof(buffer), x));
	}
}
